package cn.sz.hy.ui.widget.top;


import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.GridData;

import cn.sz.hy.adapter.top.ExecuteButtonAdapter;
import cn.sz.hy.common.Globel;

public class ExecuteBox extends BasicPanel {

	private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
	/**
	 * Create the composite.
	 * @param parent
	 * @param style
	 */
	public ExecuteBox(Composite parent, int style) {
		super(parent, style);
		addDisposeListener(new DisposeListener() {
			public void widgetDisposed(DisposeEvent e) {
				toolkit.dispose();
			}
		});
		toolkit.adapt(this);
		toolkit.paintBordersFor(this);
		setLayout(new GridLayout(2, false));
		
		Combo combo = new Combo(this, SWT.NONE);
		eBus.addComponent(Globel.EXECUTE_LIST_ID, combo);
		GridData gd_combo = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
		gd_combo.widthHint = 286;
		combo.setLayoutData(gd_combo);
		initSelected(combo);
		toolkit.adapt(combo);
		toolkit.paintBordersFor(combo);
		
		Button button = new Button(this, SWT.NONE);
		GridData gd_button = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
		gd_button.widthHint = 78;
		button.setLayoutData(gd_button);
		button.addMouseListener(new ExecuteButtonAdapter());
		toolkit.adapt(button, true, true);
		button.setText("处理");

	}
	private void initSelected(Combo combo) {
		combo.add("将抽取字段合并到源文件", 0);
		combo.select(0);
	}
}
